// UserAccessLogMapper.java
package com.example.smartgreenhouse.mapper;

import com.example.smartgreenhouse.entity.UserAccessLog;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.Date;

public interface UserAccessLogMapper {
    @Insert("INSERT INTO user_access_log(user_id, access_time) VALUES(#{userId}, #{accessTime})")
    void insertAccessLog(
            @Param("userId") Long userId,      // 添加 @Param 注解
            @Param("accessTime") Date accessTime
    );

//    @Select("SELECT COUNT(*) FROM user_access_log WHERE user_id = #{userId} AND DATE(access_time) = CURDATE()")
//    Integer countTodayVisits(Long userId);
//
//    @Select("SELECT COUNT(DISTINCT DATE(access_time)) FROM user_access_log " +
//            "WHERE user_id = #{userId} AND YEARWEEK(access_time, 1) = YEARWEEK(CURDATE(), 1)")
//    Integer countWeeklyActiveDays(Long userId);
//
//    @Select("SELECT COUNT(*) FROM user_access_log WHERE user_id = #{userId}")
//    Integer countTotalVisits(Long userId);
}